from __future__ import annotations  # 必须放在文件开头
from typing import NamedTuple, Any
from math import isclose
from enum import Enum


class Point(NamedTuple):
    x: float = 0.0
    y: float = 0.0
    z: float = 0.0

    def __eq__(self, other: Any) -> bool:
        if not isinstance(other, Point):
            return False
        else:
            pairs = ((self.x, other.x), (self.y, other.y), (self.z, other.z))
            return all(isclose(s, o, rel_tol=1e-05, abs_tol=1e-08) for s, o in pairs)

    def __add__(self, other: Any) -> Point:
        if not isinstance(other, Point):
            return NotImplemented  # 不可完成的操作
        return Point(self.x + other.x, self.y + other.y, self.z + other.z)

    def __sub__(self, other: Any) -> Point:
        if not isinstance(other, Point):
            return NotImplemented
        return Point(self.x - other.x, self.y - other.y, self.z - other.z)

    def replace(self, replace:dict[str, float]) -> Point:
        # 创建当前值的字典
        current_values = self._asdict()
        # 用新值更新
        current_values.update(replace)
        # 创建新的 Point 对象
        return Point(**current_values)


class Mount(Enum):
    LEFT = "left"
    RIGHT = "right"

class Direction(Enum):
    Forward = "forward"
    Back = "back"
    Left = "left"
    Right = "right"
    Up = "up"
    Down = "down"
